package com.lzh.gulimall.seckill.config;

import org.redisson.Redisson;
import org.redisson.api.RedissonClient;
import org.redisson.config.Config;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @ClassName MyRedissonConfig
 * @Description TODO
 * @Author liuzhihui
 * @Date 2020/8/26 22:27
 * @Version 1.0
 **/
@Configuration
public class MyRedissonConfig {

    /**
     * 所有对redisson的使用都是通过RedissonClient对象
     * @return
     */
    @Bean(destroyMethod = "shutdown")
    public RedissonClient redissonClient(){
        //创建配置
        Config config = new Config();
        //单节点的配置 Redis url should start with redis:// or rediss:// (for SSL connection)
        config.useSingleServer().setAddress("redis://192.168.59.131:6379");
        //根据config创建出redissonClient示例
        RedissonClient redisson = Redisson.create(config);
        return redisson;
    }
}
